<?PHP

header('Content-type: text/plain');

if (!isset($_REQUEST['data'])) {
 header('Location: http://www.dmdirc.com/');
 die('error This subdomain is for automated requests only');
}

$_VERSIONS = array();
foreach (glob('sources/*.php') as $source) {
 include($source);
}

function checkVersion($comp, $channel, $local) {
 global $_VERSIONS;

 $remote = $_VERSIONS[$comp][$channel]['id'];
 $string = $_VERSIONS[$comp][$channel]['string'];
 $filenm = $_VERSIONS[$comp][$channel]['file'];

 if ((int) $remote > (int) $local || ((int) $local > 20070000 && (int) $remote < 20070000)) {
  echo "outofdate $comp $channel $remote $string $filenm\n";
 } else {
  echo "uptodate Component $comp is at the latest version offered by channel $channel\n";
 }
}

foreach (explode(';', $_REQUEST['data']) as $request) {
 list($comp, $channel, $localversion) = explode(',', $request);

 if (empty($comp)) { continue; }

 if (!isset($_VERSIONS[$comp])) {
  echo "error Component $comp is not known\n";
 } else if (isset($_VERSIONS[$comp][$channel])) {
  checkVersion($comp, $channel, $localversion);
 } else if (isset($_VERSIONS[$comp]['ALL'])) {
  checkVersion($comp, 'ALL', $localversion);
 } else {
  echo "uptodate Component $comp has no presence in channel $channel\n";
 }
}

?>
